package com.ruoyi.common.enums.business;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum UserKocLevelEnum {

    /**
     * 避坑 id一定不要变 id 变了要手动改回来
     */
    KOC_0(0L, "0", "非KOC用户", "非KOC用户"),

    GH_KOC_1(1L, "1", "官号KOC1级", "官号KOC1级"),

    XHS_KOC_2(2L, "2", "小红书KOC2级", "小红书KOC2级"),

    PX_KOC_2(3L, "3", "品宣KOC2级", "品宣KOC2级"),

    SQ_KOC_3(4L, "4", "社群KOC3级", "社群KOC3级"),


    ;

    private final Long kocLevelId;

    private final String code;

    private final String name;

    private final String desc;


    private static final Map<Long, UserKocLevelEnum> ENUM_MAP;

    static {
        UserKocLevelEnum[] values = values();
        Map<Long, UserKocLevelEnum> enToCn = new HashMap<>(values.length);
        for (UserKocLevelEnum value : values) {
            enToCn.put(value.kocLevelId, value);
        }
        ENUM_MAP = Collections.unmodifiableMap(enToCn);
    }

    /**
     * 根据类型查找枚举
     */
    public static UserKocLevelEnum getEnumByType(Long kocLevelId) {
        UserKocLevelEnum userKocLevelEnum = ENUM_MAP.get(kocLevelId);
        if (ObjectUtil.isEmpty(userKocLevelEnum)) {
            throw new RuntimeException("");
        }
        return userKocLevelEnum;
    }


}
